package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo10Union {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setMaster("local[4]").setAppName("map")
    val sc: SparkContext = new SparkContext(conf)


    val users1: RDD[User] = sc.parallelize(List(User("张三", 23), User("李四", 24)))

    val users2: RDD[User] = sc.parallelize(List(User("王五", 25), User("赵六", 26)))


    /**
      * union  合并两个类型一样的RDD
      *
      */

    val unionRDD: RDD[User] = users1.union(users2)


    unionRDD.foreach(println)

  }

  case class User(name: String, age: Int)

}
